package com.cola.clone;

/**
 * @Grup:com.cola.clone
 * @Auther:cola
 * @Data:2021/3/16-2021-03-15:52
 * @version:1.0
 * 对象需要具备克隆功能:
 * 1.实现Cloneable接口,(标记接口)
 * 2.重写Object类的clone方法
 */
public class Cat implements Cloneable{
    private String name;
    private  int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    //重写clone方法
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Cat(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Cat() {
        super();
    }
}
